package com.erli.exchange.common.sg;

import com.erli.exchange.common.sg.config.BaseClassInfo;

/**
 * Service实现类生成器
 * 
 * @title ServiceImplSourceGenerator.java
 * @package com.example.demo.sourcegenerate
 * @author lihu
 * @update 2019年3月8日 下午3:12:49
 */
public class ServiceImplSourceGenerator extends AbstractSourceGenerator {

	@Override
	protected String getFileMainContent() {
		String entityClassName = this.getEntityClassName();
		String daoClassName = this.getClassNameByBaseClassInfo(daoClassInfo);
		importSet.add(this.getFullClassImportByBaseClassInfo(entityClassInfo));
		importSet.add(this.getFullClassImportByBaseClassInfo(serviceClassInfo));
		importSet.add(this.getFullClassImportByBaseClassInfo(daoClassInfo));
		String daoInstanceName = this.getInstanceNameByClassName(daoClassName);
		return String.format(templateInfo.getServiceImplTemplate(), daoClassName, daoInstanceName,
				entityClassName, daoInstanceName);
	}

	@Override
	protected String getFileFirstLineContent() {
		return String.format(templateInfo.getFileStart(), baseInfo.getClassType(), getClassName(),
				String.format(this.getSelfClassInfo().getExtendsTemplate(), this.getEntityClassName(),
						this.getClassNameByBaseClassInfo(serviceClassInfo)));
	}

	@Override
	protected BaseClassInfo getSelfClassInfo() {
		return serviceImplClassInfo;
	}
}
